#include "stdafx.h"
#include "DownApp.h"
#include "DownDlgEx.h"


BEGIN_MESSAGE_MAP(CDownApp, CWinApp)
END_MESSAGE_MAP()

CDownApp::CDownApp()
{
}



CDownApp theApp;



BOOL CDownApp::InitInstance()
{
	WNDCLASS    wndClass;
	::GetClassInfo(AfxGetInstanceHandle(), "#32770", &wndClass);
    wndClass.lpszClassName = CLIENT_DOWN_CLASS;
    AfxRegisterClass(&wndClass);



	InitCommonControls();
	CWinApp::InitInstance();
	AfxEnableControlContainer();

	int nCheckCount = 0;
	static const char szProgName[] = CLIENT_DOWN_MUTEX;
    CreateMutex(NULL, TRUE, szProgName);

	while(1)
	{
		if (GetLastError() == ERROR_ALREADY_EXISTS)
		{
			if(nCheckCount== 3)
			{
				return FALSE;
			}
			else
			{
				nCheckCount ++;
				Sleep(500);
			}
		}
		else
			break;
	}


	CDownDlgEx dlg;
	m_pMainWnd = &dlg;
	dlg.DoModal();
	return FALSE;
}
